using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class SevenZip_Buffer_OutBuffer_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            Type[] args;
            Type type = typeof(SevenZip.Buffer.OutBuffer);
            args = new Type[]{typeof(System.IO.Stream)};
            method = type.GetMethod("SetStream", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, SetStream_0);
            args = new Type[]{};
            method = type.GetMethod("FlushStream", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, FlushStream_1);
            args = new Type[]{};
            method = type.GetMethod("CloseStream", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, CloseStream_2);
            args = new Type[]{};
            method = type.GetMethod("ReleaseStream", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, ReleaseStream_3);
            args = new Type[]{};
            method = type.GetMethod("Init", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Init_4);
            args = new Type[]{typeof(System.Byte)};
            method = type.GetMethod("WriteByte", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, WriteByte_5);
            args = new Type[]{};
            method = type.GetMethod("FlushData", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, FlushData_6);
            args = new Type[]{};
            method = type.GetMethod("GetProcessedSize", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, GetProcessedSize_7);



            app.RegisterCLRCreateArrayInstance(type, s => new SevenZip.Buffer.OutBuffer[s]);

            args = new Type[]{typeof(System.UInt32)};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* SetStream_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.IO.Stream @stream = (System.IO.Stream)typeof(System.IO.Stream).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.SetStream(@stream);

            return __ret;
        }

        static StackObject* FlushStream_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.FlushStream();

            return __ret;
        }

        static StackObject* CloseStream_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.CloseStream();

            return __ret;
        }

        static StackObject* ReleaseStream_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.ReleaseStream();

            return __ret;
        }

        static StackObject* Init_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Init();

            return __ret;
        }

        static StackObject* WriteByte_5(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Byte @b = (byte)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.WriteByte(@b);

            return __ret;
        }

        static StackObject* FlushData_6(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.FlushData();

            return __ret;
        }

        static StackObject* GetProcessedSize_7(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            SevenZip.Buffer.OutBuffer instance_of_this_method = (SevenZip.Buffer.OutBuffer)typeof(SevenZip.Buffer.OutBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.GetProcessedSize();

            __ret->ObjectType = ObjectTypes.Long;
            *(ulong*)&__ret->Value = result_of_this_method;
            return __ret + 1;
        }




        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.UInt32 @bufferSize = (uint)ptr_of_this_method->Value;


            var result_of_this_method = new SevenZip.Buffer.OutBuffer(@bufferSize);

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
